package pers.zh.parking.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.zh.parking.common.BaseController;
import pers.zh.parking.common.Response;
import pers.zh.parking.po.Evaluation;
import pers.zh.parking.service.IEvalService;
import pers.zh.parking.service.IParkRecordService;

@RestController
@RequestMapping("eval")
public class EvalController extends BaseController {

    @Autowired
    IParkRecordService recordService;
    @Autowired
    IEvalService evalService;

    @GetMapping("list/{userId}")
    public Response list(@PathVariable Integer userId) {
        return Response.ok(recordService.getEvals(userId));
    }

    @PostMapping("update")
    public Response update(@RequestBody Evaluation evaluation) {
        if (evaluation.getRecordId() == null) {
            return Response.fail_500("停车记录id不能为空");
        }
        if (evaluation.getEvalLevel() == null) {
            return Response.fail_500("评价等级不能为空");
        }
        if (evalService.update(evaluation)) {

        }
        return Response.ok();
    }

}
